package org.breathe.thread.pool.common.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.breathe.thread.pool.common.constant.BreatheDtpConstant;
import org.breathe.thread.pool.common.enums.QueueTypeEnum;
import org.breathe.thread.pool.common.enums.RejectedTypeEnum;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * 线程池的配置信息
 * @author: breathe
 * @createTime: 2025-04-08
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Accessors(chain = true)
public class ThreadPoolExecutorProperties {
    /**
     * 动态线程池的名字
     */
    private String threadPoolName = "breathe:dtp";

    /**
     * 核心线程数
     */
    private Integer corePoolSize = 1;

    /**
     * 最大线程数
     */
    private Integer maximumPoolSize = BreatheDtpConstant.AVAILABLE_PROCESSORS;

    /**
     * 队列容量
     */
    private Integer queueCapacity = 1024;

    /**
     * 阻塞队列
     */
    private String queueType = QueueTypeEnum.VARIABLE_LINKED_BLOCKING_QUEUE.getName();

    /**
     * 如果是失败策略，那就是synchronousQueue
     */
    private Boolean fair = false;

    /**
     * 拒绝策略
     */
    private String rejectedHandlerType = RejectedTypeEnum.ABORT_POLICY.getName();

    /**
     * 活跃时长
     */
    private Long keepAliveTime = 30L;

    /**
     * 时间单位
     */
    private TimeUnit timeUnit = TimeUnit.SECONDS;

    /**
     * 是否允许核心线程超时
     */
    private boolean allowCoreThreadTimeOut = false;

    /**
     * 线程名字前缀
     */
    private String threadNamePrefix = "breathe-dtp";

    /**
     * 报警平台
     */
    private List<NotifyItem> notifyItems;
}